package com.soft.collateral.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * @author yzh
 * @desc TODO
 * @date 2025/7/28
 */
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {

    //插入时自动填充
    @Override
    public void insertFill(MetaObject metaObject) {
        this.setFieldValByName("createdAt" , LocalDateTime.now(), metaObject);
        this.setFieldValByName("applyTime" , LocalDateTime.now(), metaObject);
        this.setFieldValByName("approvalTime" , LocalDateTime.now(), metaObject);
    }


    //更新时自动填充
    @Override
    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName("updatedAt" ,  LocalDateTime.now() , metaObject);
    }
}